<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    var arr = [1,2,3];
    console.log(arr[0]);

    // var arr1 = new Array(2);//这个2为数组长度为2
    var arr1 = new Array(2,3);
    console.log(arr1);
    
    function reversr(arr1){
        if(arr1 instanceof Array){
        var newArr = [];
        for(var i = arr1.length-1;i>=0;i--){
            newArr[newArr.length] = arr[i];
        }
        return newArr;
        } else {
            return 'error 这个参数必须为数组格式';
        }
    }console.log(reversr(1,2,3));
    console.log(reversr([1,2,3]));

    //检测是否为数组
    // instanceof 运算符 它可以检测是否为数组
    var arr2 = [];
    var arr3 = {};
    console.log(arr2 instanceof Array);
    console.log(arr3 instanceof Array);

    //Array.isArray();
    console.log(Array.isArray(arr));
    console.log(Array.isArray(arr3));
</script>
<body>
    
</body>
</html>